import time
import yaml
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

from page.basePage import basePage

with open(r'D:\PycharmProjects\ecShop\autoTest\driver\elements.yml','r',encoding='utf-8') as file:
    elements_config = yaml.safe_load(file)

class addspct2Page(basePage):
    url = "http://localhost:8800/ecshop/"
    classify_btn = By.XPATH, elements_config['addspct2_page']['classify_btn']
    commodity_btn = By.XPATH,elements_config['addspct2_page']['commodity_btn']
    add_btn = By.XPATH,elements_config['addspct2_page']['add_btn']
    checkout_btn = By.XPATH,elements_config['addspct2_page']['checkout_btn']

    def click_classify(self):
        self.find_Element(self.classify_btn).click()

    def click_commodity(self):
        self.find_Element(self.commodity_btn).click()

    def click_add(self):
        self.find_Element(self.add_btn).click()

    def click_checkout(self):
        self.find_Element(self.checkout_btn).click()

    def fun_addspct2(self):
        self.open(self.url)
        time.sleep(2)
        self.click_classify()
        time.sleep(1)
        self.click_commodity()
        self.click_add()
        time.sleep(1)
        self.click_checkout()
        time.sleep(1)




